<template>
  <!-- 前端展示首页 -->
  <div class="container" v-if="pageData" :style="backgroundStyle">
    <div class="header">
      <div class="w">
        <div class="header-logo">
          <div class="sitelogocon">
            <!-- <img border="0" src="@/assets/images/web/logo.png" /> -->
            <img border="0" :src="define.comUrl + pageData.schoolemblemimageobj.url" />
          </div>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="content">
        <ul>
          <li style="height:80px;margin-top:80px">
            <h4>{{ pageData.title }}</h4>
          </li>
          <li style="height:60px;margin-left:-10px;margin-top:20px;">
            <button type="submit" class="btn"
              @click="goNext(pageData.leftbutton,pageData.undergraduate)">
              {{ pageData.leftbutton }}
            </button>
            <button type="submit" class="btn"
              @click="goNext(pageData.rightbutton,pageData.postgraduate)">
              {{ pageData.rightbutton }}
            </button>
          </li>
        </ul>
      </div>
    </div>
    <div class="footer">
      <div class="copyright">{{ pageData.imprint }}</div>
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  components: {},
  props: {},
  computed: {
    backgroundStyle() {
      return {
        background: `url(${this.define.comUrl}${this.pageData.backgroundimageobj.url
          })`
      };
    }
  },
  data() {
    return {
      pageData: null
    };
  },
  created() {
    this.getHome();
  },
  mounted() { },
  methods: {
    getHome() {
      request({
        url: "/api/example/MzGateway/getList",
        method: "post",
        data: {
          sort: "desc"
        }
      }).then(res => {
        this.pageData = res.data.list[0];
        if (this.pageData.schoolemblemimage) {
          this.pageData.schoolemblemimageobj = JSON.parse(
            this.pageData.schoolemblemimage
          )[0];
        }
        if (this.pageData.backgroundimage) {
          this.pageData.backgroundimageobj = JSON.parse(
            this.pageData.backgroundimage
          )[0];
        }
        if (this.pageData.backgroundsecondary) {
          this.pageData.backgroundsecondaryobj = JSON.parse(
            this.pageData.backgroundsecondary
          )[0];
        }
        if (this.pageData.backgroundthird) {
          this.pageData.backgroundthirdobj = JSON.parse(
            this.pageData.backgroundthird
          )[0];
        }
        this.jnpf.storageSet({ web_home_data: this.pageData });
      });
    },
    goNext(name, id) {
      this.$router.push({ path: "/projectForm", query: { title: name, id: id } });
    }
  }
};
</script>
<style src="../../assets/css/styles.css"  scoped>
</style>
